<template>
  <div>
    <nav-bar :title="title"></nav-bar>

    <van-cell-group title="优惠卡授权信息" v-if="flag == true">
      <van-cell title="优惠卡" :value="card.card_name"></van-cell>
      <van-cell title="面值" :value="card.amount + '元'"></van-cell>
      <van-cell title="使用商家" :value="card.retailer_name"></van-cell>
      <van-cell title="使用说明" :value="card.comment"></van-cell>
      <van-cell title="折扣率" :value="card.discount + '%'"></van-cell>
      <van-cell title="审核状态" :value="card.ack_name"></van-cell>
    </van-cell-group>
    <van-empty :description="message" v-else> </van-empty>
    <div style="margin: 32px 96px">
      <van-button round block type="primary" @click="goHome">返回</van-button>
    </div>
  </div>
</template>

<script>
import { mapGetters } from "vuex";
import NavBar from "@/components/NavBar";
import { discountCardVerify } from "@/api/card";
export default {
  name: "RetailerCardVerify",
  components: {
    NavBar,
  },

  computed: {
    ...mapGetters(["retailer_id"]),
  },

  props: ["card_id"],
  data() {
    return {
      title: this.$route.meta.title,
      form: {
        card_id: this.card_id,
        comment: this.$route.query.comment,
        discount: this.$route.query.discount,
        pid: this.$route.query.pid,
        key: this.$route.query.key,
      },
      flag: false,
      card: {},
    };
  },
  mounted() {
    console.log(this.card_id, this.retailer_id);
    this.getDiscountCardVerify();
  },
  methods: {
    goHome() {
      this.$router.push({ name: "Card" });
    },
    getDiscountCardVerify() {
      discountCardVerify(this.form)
        .then((res) => {
          console.log(res);
          const data = res.data;
          if (data.status_code == 200) {
            this.card = data.data;
            this.flag = true;
            this.$toast.success(data.message);
            // this.$router.push(`/employee/${data.employee.id}`);
          } else {
            this.$toast(data.message);
          }
        })
        .catch((error) => {
          this.$toast("审核失败!" + error);
        });
    },
  },
};
</script>

<style  scoped>
.img_outer {
  margin: 20px;
  margin-top: 5px;
  display: flex;
  justify-content: center;
}
.title {
  text-align: center;
  margin: 0;
}
.points {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 80px;
  background-color: #f2f3f5;
}
.van-field__label {
  color: black;
}
.van-col {
  margin: 5px;
  padding: 0px;
}
</style>